#include "GameMain.h"

void GameMainButton::init()
{
	do
	{
		CCMenuItemImage *bag = CCMenuItemImage::create("CloseNormal.png","CloseSelected.png",GameMain::sharedGameMain()->getButtonLayer(),menu_selector(GameMainButton::onClick));
		bag->setTag(0);
		bag->setPosition(ccp(50,50));
		CC_BREAK_IF(!bag);

		CCMenuItemImage *hero = CCMenuItemImage::create("CloseNormal.png","CloseSelected.png",GameMain::sharedGameMain()->getButtonLayer(),menu_selector(GameMainButton::onClick));
		hero->setTag(1);
		hero->setPosition(ccp(100,50));
		CC_BREAK_IF(!hero);

		CCMenuItemImage *equip = CCMenuItemImage::create("CloseNormal.png","CloseSelected.png",GameMain::sharedGameMain()->getButtonLayer(),menu_selector(GameMainButton::onClick));
		equip->setTag(2);
		equip->setPosition(ccp(150,50));
		CC_BREAK_IF(!equip);

		CCMenu *menu = CCMenu::create(bag,hero,equip,NULL);
		CC_BREAK_IF(!menu);
		menu->setPosition(CCPointZero);
		GameMain::sharedGameMain()->getButtonLayer()->addChild(menu);
	}while(0);
}

void GameMainButton::onClick(CCObject* pSender)
{
	CCMenuItemImage *item = (CCMenuItemImage *)pSender;
	switch(item->getTag())
	{
	case 0:
		CCLog("open bag");
		break;
	case 1:
		CCLog("open hero");
		break;
	case 2:
		CCLog("open equip");
		break;
	};
}